$(document).ready(function() {

    //Sidebar Accordion Menu:

    $("#main-nav li ul").hide(); //Hide all sub menus
    $("#main-nav li a.current").parent().find("ul").slideToggle("slow"); // Slide down the current menu item's sub menu

    $("#main-nav li a.nav-top-item").click( // When a top menu item is clicked...
			function() {
			    $(this).parent().siblings().find("ul").slideUp("normal"); // Slide up all sub menus except the one clicked
			    $(this).next().slideToggle("normal"); // Slide down the clicked sub menu

			    if ($(this).attr("href") == null || $(this).attr("href") == "" || $(this).attr("href") == "#") {
			        return false;
			    }
			}
		);

    // Sidebar Accordion Menu Hover Effect:

    $("#main-nav li .nav-top-item").hover(
			function() {
			    $(this).stop();
			    $(this).animate({ paddingRight: "25px" }, 200);
			},
			function() {
			    $(this).stop();
			    $(this).animate({ paddingRight: "15px" });
			}
		);

    //Minimize Content Box

    $(".content-box-header h3").css({ "cursor": "s-resize" }); // Give the h3 in Content Box Header a different cursor
    $(".content-box-header-toggled").next().hide(); // Hide the content of the header if it has the class "content-box-header-toggled"

    $(".content-box-header h3").click( // When the h3 is clicked...
			function() {
			    $(this).parent().parent().find(".content-box-content").toggle(); // Toggle the Content Box
			    $(this).parent().toggleClass("content-box-header-toggled"); // Give the Content Box Header a special class for styling and hiding
			    $(this).parent().find(".content-box-tabs").toggle(); // Toggle the tabs
			}
		);

    // Content box tabs:

    $('.content-box .content-box-content div.tab-content').hide(); // Hide the content divs
    $('.content-box-content div.default-tab').show(); // Show the div with class "default-tab"
    $('ul.content-box-tabs li a.default-tab').addClass('current'); // Set the class of the default tab link to "current"

    $('.content-box ul.content-box-tabs li a').click( //When a tab is clicked...
			function() {
			    $(this).parent().siblings().find("a").removeClass('current'); // Remove "current" class from all tabs
			    $(this).addClass('current'); // Add class "current" to clicked tab
			    var currentTab = $(this).attr('href'); // Set variable "currentTab" to the value of href of clicked tab
			    $(currentTab).siblings().hide(); // Hide all content divs
			    $(currentTab).show(); // Show the content div with the id equal to the id of clicked tab
			    return false;
			}
		);

    // Check all checkboxes when the one in a table head is checked:

    $('.check-all').click(
			function() {
			    $(this).parent().parent().parent().parent().find("input[type='checkbox']").attr('checked', $(this).is(':checked'));
			}
		)

});
  
  
  